package com.evil.application.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.evil.application.pojo.entity.ControlPermission;
import com.evil.common.application.dto.permission.control.ControlPermissionSourceDTO;
import com.evil.common.application.dto.permission.control.ControlPermissionsReqDTO;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

/**
 * 控件权限配置表
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
public interface ControlPermissionMapper extends BaseMapper<ControlPermission> {

    List<ControlPermission> findBySource(ControlPermissionSourceDTO controlPermissionReqDTO);

    List<ControlPermission> findByControlPermissions(ControlPermissionsReqDTO controlPermissionsReqDTO);

    List<ControlPermission> findBySources(@Param("sources") Collection<ControlPermissionSourceDTO> sources);

    Optional<ControlPermission> findControlPermission(@Param("sourceType") Integer sourceType,
                                                      @Param("sourceId") Long sourceId,
                                                      @Param("controlId") Long controlId);
}